const webpackCommon =  require('./webpack.common')
const { merge } = require('webpack-merge')
const CopyPlugin = require("copy-webpack-plugin")
const config = require('./webpack.cfg')
// const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')

module.exports = (env) => {
  return merge(webpackCommon('build', env), {
    mode: 'production',
    optimization: {
      // css 压缩
      minimize: true,
      minimizer: [
        new CssMinimizerPlugin(),
        '...'
      ]
    },
    plugins: [
      // new CleanWebpackPlugin(),
      // 公共文件拷贝
      new CopyPlugin({
        patterns: [
          {from: config.build.public, to: config.build.public}
        ]
      })
    ]
  })
}
